<template>
    <div class="top">
        <headIndex />
        <div class="article">
            <div class="main_cer" style="background: #ffffff;padding:20px 20px 60px">
                <!----当前位置----->
                <div class="dqwz">
                    <div class="wz">
                        <span>当前位置</span>
                        <span>></span>
                        <span><a href="/home">首页</a></span>
                        <span>></span>
                        <span><a :href="'/list?catid=' + catID" target="_blank">{{ art_obj.categoryname }}</a></span>
                        <span>></span>
                        <span>正文</span>
                    </div>
                </div>
                <div class="cont">
                    <div class="title">
                        <h1>{{ art_obj.infotitle }}</h1>
                        <div class="author">
                            <!-- <span>来源：中国军网-解放军报</span> -->
                            <!-- <span v-if="art_obj.author != ''">作者：{{ art_obj.author }}</span> -->
                            <!-- <span>责任编辑：孙悦</span> -->
                            <span>发布：{{ art_obj.addtime }}</span>
                            <span>阅读量：{{ art_obj.clicknum }}</span>
                        </div>
                    </div>
                    <div class="zw" v-html="art_obj.infocontent" style="padding-top:20px">

                    </div>
                </div>
            </div>                              
        </div>


        <footIndex />
    </div>
</template>  
<script setup name="article">
import headIndex from './components/headIndex/index.vue'
import footIndex from './components/footIndex/index.vue'
import { oneInfo, addNum } from "@/api/yxzx/info"; 
export default {
    components: {
        headIndex,
        footIndex
    },
    data() {
      return {
        art_obj: {},
        catID: '',
      }
    },
    created() {
        this.getArt()
        this.addRead()
    },
    methods: {
        getArt() {
            oneInfo(this.GetQueryString('id')).then((response) => {
                document.title = response.infotitle
                this.art_obj = response
                this.catID = response.categoryid
            })
        },
        addRead() {
            addNum (this.GetQueryString('id')).then((response) => {
                console.log('success')
            })
        },
        
        // 获取地址栏的参数
        GetQueryString (name) {
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
            var r = window.location.search.substr(1).match(reg)
            if (r != null) {
            return decodeURI(r[2])
            } else {
            return null
            }
        },
    }  
}
</script>
<style>
.main_ny .article .cont a img{
   width: 16px;
   height: 16px; 
}
</style>   